package com.kaung.springcloud.controller;

import com.kuang.springcloud.pojo.Dept;
import com.kuang.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.annotation.Resource;
import java.util.List;

@RestController
public class DeptConsumerController {


    //private static final String REST_URL_PREFIX = "http://localhost:8001";
    //通过Ribbon负载均衡之后,地址应该是一个变量,通过服务名来访问
   // private static final String REST_URL_PREFIX = "SPRINGCLOUD-PROVIDER-DEPT";

    //使用feign的话就采用feign的方式进行调用
    @Resource
    private DeptClientService service;


    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept){
        return this.service.addDept(dept);
    }

    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id){
        return this.service.queryById(id);

    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> list(){
        return this.service.queryAll();
    }

}
